package tql.delayqueue.partition.assigner.impl

import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import tql.delayqueue.config.NamespaceConfig
import tql.delayqueue.partition.PartitionWorker
import tql.delayqueue.partition.assigner.PartitionAssignerFactory

class RandomPartitionAssignerServiceImplTest {
    private val randomPartitionAssignerServiceImpl = PartitionAssignerFactory.create("random")

    @Test
    fun test() {
        val worker1 = PartitionWorker(10, "worker1")
        val worker2 = PartitionWorker(10, "worker2")
        val worker3 = PartitionWorker(10, "worker3")
        val workers = listOf(worker1, worker2, worker3)
        val namespaceConfig = NamespaceConfig("testSameWeight", 9, 1)
        val workersPartitionMap = randomPartitionAssignerServiceImpl.assignWorkersPartition(namespaceConfig, workers)
        println(workersPartitionMap)
        Assertions.assertTrue {workersPartitionMap.keys.distinct().size > 1}
    }
}